﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExtenstionFunctions
{
    public static class ExtFunctions
    {
        public static decimal SumDecimal<T>(this IEnumerable<T> collection)
        {
            decimal sum = 0;
            foreach (T item in collection)
            {
                sum += Convert.ToDecimal(item);
            }
            return sum;
        }

        public static decimal AvgDecimal<T>(this IEnumerable<T> collection)
        {
            decimal sum = 0;
            foreach (T item in collection)
            {
                sum += Convert.ToDecimal(item);
            }
            int count = collection.Count();
            return sum/count;
        }

        public static T MaxDecimal<T>(this IEnumerable<T> collection) where T : IComparable<T>
        {
            return collection.Max();
        }

        public static T MinDecimal<T>(this IEnumerable<T> collection) where T : IComparable<T>
        {
            return collection.Min();
        }
    }
}
